import static org.junit.Assert.*;
import junit.framework.Assert;

import org.junit.Test;

import DBLayer.DbConnection;
import DBLayer.DBClothing;
import ModelLayer.Clothing;


public class DBClothingTest {
	
	DBClothing dbClothing = new DBClothing();;
	 Clothing clo = new Clothing(18, "Hat", 15.99, 18.99, 15.99, "Romania", 10, 12, 4, "xxls","Red");
	 
	@Test
	public void test() 
	{
		//testFindClo(18);
		//testInsert();
		//testDelete(18);
		testUpdate(18);
	}
	
	
	void testUpdate(int idd)
	{
		clo.setColour("Blue");
		clo.setCountryOfOrigin("Angola");
		int rc = dbClothing.update(clo);
		
		Assert.assertEquals(1, rc);
	}
	
	
	void testFindClo(int idd)
	{
		Clothing clo = null;
		try {
			clo = (Clothing) dbClothing.find_byID(idd);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		Assert.assertNotNull(clo);
	}
	
	void testDelete(int idd)
	{
		
		int rc = -1;
		try {
			rc = dbClothing.delete(idd);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		Assert.assertEquals(1, rc);
		
	}
	
	void testInsert()
	{
		int rc = -1;
		try {
			
			rc = dbClothing.insert(clo);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		Assert.assertEquals(1, rc);
	}
	

}
